//
//  DocumentBuilder.h
//  iFlickr
//
//  Created by 张 霄鹤 on 09-7-5.
//  Copyright 2009 xhzhang. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "Document.h"
#import "Stack.h"


@interface DocumentBuilder : NSObject<NSXMLParserDelegate> {
	Stack *level;
	BOOL success;
}

/**
 * 快捷方法，创建 DocumentBuilder
 */
+(id)makeDocumentBuilder;


/**
 * 解析数据，直接通过字符串最终解析成为 Document *
 */
- (BOOL)parseWithString:(NSString *)xml toResult:(Document *)dom;

/**
 * 通过NSData进行解析
 */
- (BOOL)parseWithData:(NSData *)data toResult:(Document *)dom;

/**
 * 文档开始
 */
- (void)parserDidStartDocument:(NSXMLParser *)parser;

/**
 * 标签开始
 */
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string;

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;

/**
 * 文档结束 用于清空 tags
 */
- (void)parserDidEndDocument:(NSXMLParser *)parser;

@end
